/*
 * @Author: admin
 */

// 标签复制-文本赋值到input
function copyText() {
	var that = event.currentTarget;
  var text = $(that).children("span.copy").html();
  var input = document.getElementById("input");
  input.value = text; // 修改文本框的内容
  input.select(); // 选中文本
  document.execCommand("copy"); // 执行浏览器复制命令
  // alert("复制成功");
};
// 代码复制-textarea
function copyTextarea() {
	var that = event.currentTarget;
  var text = $(that).siblings("textarea");
  text.select(); // 选中文本
  document.execCommand("copy"); // 执行浏览器复制命令
  // alert("复制成功");
};
// 通用tab栏目切换效果，支持多个页面使用
function tabs(tabTit,on,tabCon){
  $(tabTit).children().click(function(){
    $(this).addClass(on).siblings().removeClass(on);
    var index = $(tabTit).children().index(this);
    $(tabCon).children().eq(index).show().siblings().hide();
  });
};
tabs(".tab-hd","active",".tab-bd"); // 修改此处参数
// 手机端导航切换
var i = 0;
$(document).ready(function(){
  $(".menu").click(function(){
    $('.tool-container').toggleClass('menu_click');
    if (i == 0) {
    	$(".tool-nav").fadeIn();
	    i = 1;
    } else {
    	$(".tool-nav").fadeOut();
    	i = 0;
    }
  });
});

// 以下是自动生成助手JS代码

// 导航生成
function nav1(){
  var num = document.getElementById("num").value;
  if (num > 0) {
    var num = ' num=' + num;
  } else {
    var num = "";
  }
  var id = document.getElementById("id").value;
  if (id > 0) {
    var id = ' parent=' + id;
  } else {
    var id = "";
  }
  var sum = '    <li class="{pboot:if(0==' + "'{sort:scode}'" + ')}active{/pboot:if}"><a href="{pboot:sitepath}/">首页</a></li>' + "\n"
  + "{pboot:nav" + num + id + '}' + "\n"
  + '    <li {pboot:if(' + "'[nav:scode]'" + '==' + "'{sort:tcode}'" + ')}class="active"{/pboot:if}><a href="[nav:link]" title="[nav:name]">[nav:name]</a></li>' + "\n"
  + '{/pboot:nav}';
  document.getElementById("nav").value = sum;
};
// 二级导航
function nav2(){
  var sum = '    <li {pboot:if(0==' + "'{sort:scode}'" + ')}class="active"{/pboot:if}><a href="{pboot:sitepath}/">首页</a></li>' + "\n"
  + '{pboot:nav}' + "\n"
  + '    <li{pboot:if(' + "'[nav:scode]'" + '==' + "'{sort:tcode}'" + ')} class="active"{/pboot:if}><a href="[nav:link]" title="[nav:name]">[nav:name]</a></li>' + "\n"
  + '    {pboot:if([nav:soncount]>0)}' + "\n"
  + '        <ul class="">' + "\n"
  + '        {pboot:2nav  parent=[nav:scode]}' + "\n"
  + '            <li><a href= "[2nav:link]" title="[2nav:name]">[2nav:name]</a></li>' + "\n"
  + '        {/pboot:2nav}' + "\n"
  + '        </ul>' + "\n"
  + '    {/pboot:if}' + "\n"
  + '{/pboot:nav}';
  document.getElementById("nav").value = sum;
};
// 三级导航
function nav3(){
  var sum =  '    <li{pboot:if(0==' + "'{sort:scode}'" + ')} class="active"{/pboot:if}><a href="{pboot:sitepath}/">首页</a></li>' + "\n"
  + '{pboot:nav}' + "\n"
  + '    <li><a href="[nav:link]" title="[nav:name]">[nav:name]</a></li>' + "\n"
  + '    {pboot:if([nav:soncount]>0)}' + "\n"
  + '        {pboot:2nav  parent=[nav:scode]}' + "\n"
  + '            <li><a href= "[2nav:link]" title="[2nav:name]">[2nav:name]</a></li>' + "\n"
  + '            {pboot:2if([2nav:soncount]>0)}' + "\n"
  + '            {pboot:3nav  parent=[2nav:scode]}' + "\n"
  + '                <li><a href= "[3nav:link]" title="[3nav:name]">[3nav:name]</a></li>' + "\n"
  + '            {/pboot:3nav}' + "\n"
  + '            {/pboot:2if}' + "\n"
  + '        {/pboot:2nav}' + "\n"
  + '    {/pboot:if}' + "\n"
  + '{/pboot:nav}';
  document.getElementById("nav").value = sum;
};

// 模板复用-ok
function include(){
  var id = document.getElementById("id1").value;
  if (id != "") {
    var id = document.getElementById("id1").value;
  } else {
    var id = 'head';
  }
  var sum = '{include=' +'"' + id +'"' + '}';
  document.getElementById("include").value = sum;
};
// 时间格式化 -ok
function time(){
  var list = document.getElementById("list1").value;
  var time =  document.getElementById("format").value;
  if (time == 1 ) {
    var time = 'Y/m/d';
  } else if (time == 0) {
    var time = 'Y-m-d';
  } else if (time == 2) {
    var time = 'Y年m月d日';
  } else if (time == 3) {
    var time = 'Y年m月';
  } else if (time == 4) {
    var time = 'Y-m-d H:i:s';
  }
  if (list == 1 ) {
    var list = '{fun date(\'';
    var num = list  + time + '\',$jz[\'addtime\'])' +'}' ;
    document.getElementById("time").value = num;
  } else {
    var list = '{fun date(\'';
    var num = list + time + '\',$v[\'addtime\'])' +'}' ;
    document.getElementById("time").value = num;
  }
};

// 列表文本截断-ok
function lencn(){
    
   var list2 =  document.getElementById("list2").value;
  if (list2 == 0) {
    var list2 = '($v[\'title\'],'
  } else if (list2 == 1) {
    var list2 = '($v[\'description\'],';
  } else if (list2 == 2) {
    var list2 = '(htmldecode($v[\'body\']),';
  } 
   var num = document.getElementById("num2").value;
  if (num > 0) {
    var num = + num;
  } else {
    var num = '40';
  }
    var list = '{fun newstr';
    var num = list + list2 + num  + ')}' ;
    document.getElementById("lencn").value = num;
};
// 面包屑菜单
function position(){
  var num = document.getElementById("num5").value;
  if (num == "") {
    var num = "";
  } else {
    var num = " separator=''" + num;
  }
  var id = document.getElementById("id5").value;
  if (id != "") {
    var id = " indextext='"  + id + "'"
  } else {
    var id = '';
  }
  var sum = "{pboot:position" + num + id + "}";
  document.getElementById("position").value = sum;
};
// QQ
function qq(){
  var num = document.getElementById("num6").value;
  if (num > 0) {
    var num = document.getElementById("num6").value;
  } else {
    alert("QQ号不小于0且不能为空和汉字！");
    return false;
  }
  var id = document.getElementById("id6").value;
  if (id != "") {
    var id = document.getElementById("id6").value;
  } else {
    alert("QQ提示文字不能为空！");
    return false;
  }
  var sum = '<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&amp;uin=' + num + '&amp;site=qq&amp;menu=yes">'  + id + '</a>';
  document.getElementById("qq").value = sum;
};
// 列表标签1-ok
function sort(){
  var tid = document.getElementById("tid").value;
  if (tid > 0) {
    var tid = ' tid="' + tid +'"';
  } else {
    var tid = "";
  }
  
  var limit = document.getElementById("limit").value;
  if (limit > 0) {
    var limit = ' limit="' + limit +'"';
  } else {
    var limit = ' limit="8"';
  }

  var ispage =  document.getElementById("ispage").value;
  if (ispage == 0) {
    var ispage = ''
  } else if (ispage == 1) {
    var ispage = '  ispage="1"';
  }

  var table =  document.getElementById("table").value;
  if (table == 0) {
    var table = ' table="article"'
  } else if (table == 1) {
    var table = ' table="product"';
  }

  var order =  document.getElementById("order").value;
  if (order == 0) {
    var order = ''
  } else if (order == 1) {
    var order = ' orderby="id desc"';
  } else if (order == 2) {
    var order = ' orderby="id asc"';
  } else if (order == 3) {
    var order = ' orderby="addtime desc"';
  } else if (order == 4) {
    var order = ' orderby="addtime asc" ';
  }
  
    var listl =  document.getElementById("listl").value;
  if (listl == 0 ) {
    var listl = '    <li><a href="{$v[\'url\']}">{$v[\'title\']}</a></li> '
  } else if (listl == 1) {
    var listl = '    <li> {$v_key} <a href="{$v[\'url\']}">{$v[\'title\']}</a></li> '
  } else if (listl == 2) {
    var listl = '    <li> {$v_n} <a href="{$v[\'url\']}">{$v[\'title\']}</a></li> '
  } else if (listl == 3) {
    var listl = '    {if($v[\'litpic\'])}<img src="{$v[\'litpic\']}"/>{/if} \n    <li> <a href="{$v[\'url\']}">{$v[\'title\']}</a> </li>'
  } else if (listl == 4) {
    var listl = '    {if($v[\'litpic\'])}<img src="{$v[\'litpic\']}"/>{else}<img src="/noimg.jpg">{/if} \n    <li> <a href="{$v[\'url\']}">{$v[\'title\']}</a> </li>'
  }
  
  var isall =  document.getElementById("isall").value;
  if (isall == 0) {
    var isall = ''
  } else if (isall == 1) {
    var isall = ' isall="1"';
  }
  var sum = "{loop" + table + tid + limit + ispage + order  + isall +' as="v"' + '}' + "\n"
    + listl + "\n"
    + '{/loop}';
  document.getElementById("sort").value = sum;
};
// 列表标签2
function sort2(){
  var num = document.getElementById("num8").value;
  if (num > 0) {
    var num = ' limit=' + num;
  } else {
    var num = "";
  }
  var id = document.getElementById("id8").value;
  if (id > 0) {
    var id = ' starts=' + id;
  } else {
    var id = "";
  }
  var order =  document.getElementById("order2").value;
  if (order == 1 ) {
    var order = ' order=date';
  } else if (order == 0) {
    var order = "";
  } else if (order == 2) {
    var order = ' order=visits';
  } else if (order == 3) {
    var order = ' order=likes';
  } else if (order == 4) {
    var order = ' order=oppose';
  } else if (order == 5) {
    var order = ' order=sorting';
  }
  var sum = "{pboot:sort scode={sort:scode}}" + "\n"
    + "    {pboot:list" + " scode=[sort:scode] " + num + id + order + '}' + "\n"
    + '        <a href="[list:link]" title="[list:title]">[list:title]</a>' + "\n"
    + '    {/pboot:list}' + "\n"
    + '{/pboot:sort}';
  document.getElementById("sort2").value = sum;
};
// 列表标签3
function sort3(){
  var num = document.getElementById("num9").value;
  if (num > 0) {
      var num = ' num=' + num;
  } else {
      var num = "";
  }
  var id = document.getElementById("id9").value;
  if (id > 0) {
      var id = ' starts=' + id;
  } else {
      var id = "";
  }
  var scode = document.getElementById("scode").value;
  if (scode > 0) {
      var scode = ' scode=' + scode;
  } else {
      alert("栏目ID不能为空，且不小于0，不支持汉字");
      return false;
  }
  var order =  document.getElementById("order3").value;
  if (order == 1 ) {
      var order = ' order=date';
  } else if (order == 0) {
      var order = "";
  } else if (order == 2) {
      var order = ' order=visits';
  } else if (order == 3) {
      var order = ' order=likes';
  } else if (order == 4) {
      var order = ' order=oppose';
  } else if (order == 5) {
      var order = ' order=sorting';
  }
  var sum = "{pboot:list" + scode + num + id + order + '}' + "\n"
    + '        <a href="[list:link]" title="[list:title]">[list:title]</a>' + "\n"
    + '{/pboot:list}';
  document.getElementById("sort3").value = sum;
};
// 列表标签4
function sort4(){
  var num = document.getElementById("num10").value;
  if (num > 0) {
      var num = ' num=' + num;
  } else {
      var num = "";
  }
  var order =  document.getElementById("order4").value;
  if (order == 1 ) {
      var order = ' order=date';
  } else if (order == 0) {
      var order = "";
  } else if (order == 2) {
      var order = ' order=visits';
  } else if (order == 3) {
      var order = ' order=likes';
  } else if (order == 4) {
      var order = ' order=oppose';
  } else if (order == 5) {
      var order = ' order=sorting';
  }
  var sum = "{pboot:nav" + num + order + ' parent={sort:scode}}' + "\n"
    + '    {pboot:list scode=[nav:scode]}' + "\n"
    + '        <a href="[list:link]" title="[list:title]" target="_blank">[list:title]</a>' + "\n"
    + '    {/pboot:list}' + "\n"
    + '{/pboot:nav}';
  document.getElementById("sort4").value = sum;
};
// 多图遍历
function pics(){
  var num = document.getElementById("num1").value;
  if (num > 0) {
    num = ' num=' + num;
  } else {
    num = '';
  }
  var pics =  document.getElementById("pics1").value;
  if (pics == 0) {
    sum =  "{pboot:pics" + num + ' id=[list:id]}' + "\n"
    + '    <img src="[pics:src]">' + "\n"
    + '{/pboot:pics}';
    document.getElementById("pics").value = sum;
  } else if (pics == 1) {
    sum =  "{pboot:pics" + num + ' id={content:id}}' + "\n"
    + '    <img src="[pics:src]">' + "\n"
    + '{/pboot:pics}';
    document.getElementById("pics").value = sum;
  }
};
// 碎片助手-ok
function sui(){

  var suix = document.getElementById("suix").value;
  if (suix != "") {
    var suix = document.getElementById("suix").value;
  } else {
    var suix = '碎片标识';
  }
    var suil =  document.getElementById("suil").value;
  if (suil == 0 ) {
    var suil = '    <li><a href="{$v[\'url\']}">{$v[\'title\']}</a></li> '
  } else if (suil == 1) {
    var suil = '    <li> {$v_key} <a href="{$v[\'url\']}">{$v[\'title\']}</a></li> '
  } else if (suil == 2) {
    var suil = '    <li> {$v_n} <a href="{$v[\'url\']}">{$v[\'title\']}</a></li> '
  } else if (suil == 3) {
    var suil = '    {if($v[\'litpic\'])}<img src="{$v[\'litpic\']}"/>{/if} \n    <li> <a href="{$v[\'url\']}">{$v[\'title\']}</a> </li>'
  } else if (suil == 4) {
    var suil = '    {if($v[\'litpic\'])}<img src="{$v[\'litpic\']}"/>{else}<img src="/noimg.jpg">{/if} \n    <li> <a href="{$v[\'url\']}">{$v[\'title\']}</a> </li>'
  }
  
  var sum = "{php \$jzdata=jzcachedata(" +'\'' + suix  + '\');/}' + "\n"
   + '{foreach \$jzdata as \$v}'+ "\n"
   + suil + "\n"
   + '{/foreach}';
  document.getElementById("sui").value = sum;
};

// 友情链接-ok
function link(){
  var num = document.getElementById("num1").value;
  if (num > 0) {
    var num = ' limit="' + num +'"';
  } else {
    var num = '';
  }
  var id = document.getElementById("id1").value;
  if (id > 0) {
    var id = ' tid="' + id +'"';
  } else {
    var id = '';
  } 
 
   var  isshow =  document.getElementById("isshow").value;
  if ( isshow == 0) {
    var  isshow = '';
  } else if ( isshow == 1) {
    var isshow = ' isshow=1';
  }
  
  var type =  document.getElementById("type").value;
  if (type == 0 ) {
    var type = '    <a href="{$v[\'url\']}" title="{$v[\'title\']}" target="_blank">{$v[\'title\']}</a>'
  } else if (type == 1) {
    var type = '  <li> <a href="{$v[\'url\']}" title="{$v[\'title\']}" target="_blank">{$v[\'title\']}</a> </li>'
  } else if (type == 2) {
    var type = '    <a href="{$v[\'url\']}"  target="_blank"><img src="{$v[\'linkimg\']}" alt="{$v[\'title\']}"></a>'
  } else if (type == 3) {
    var type = '  <li> <a href="{$v[\'url\']}"  target="_blank"><img src="{$v[\'linkimg\']}" alt="{$v[\'title\']}"></a>  </li>'
  }
  var sum = "{loop" +' table="links"' + id + num + isshow +' as="v"' + '}' + "\n"
   + type + "\n"
   + '{/loop}';
  document.getElementById("link").value = sum;
};
// 轮播图
function slide(){
  var limit = document.getElementById("limit").value;
  if (limit > 0) {
    var limit = ' limit="' + limit +'"';
  } else {
    var limit = ' limit="3"';
  }
  var id = document.getElementById("id1").value;
  if (id > 0) {
    var id = ' tid="' + id +'"';
  } else {
    var id = ' ';
  }
  var type =  document.getElementById("type").value;
  if (type == 0 ) {
    var type = '    <img src="{$v[\'litpic\']}" alt="{$v[\'title\']}">';
  } else if (type == 1) {
    var type = '   <li> <img src="{$v[\'litpic\']}" alt="{$v[\'title\']}"> </li>';
  }
  else if (type == 2) {
    var type = '    <a href="{$v[\'url\']}" target="_blank"><img src="{$v[\'litpic\']}" alt="{$v[\'title\']}"></a>';
  }
  else if (type == 3) {
    var type = '   <li> <a href="{$v[\'url\']}" target="_blank"><img src="{$v[\'litpic\']}" alt="{$v[\'title\']}"></a> </li>';
  }
  var sum = "{loop" +' table="collect"' + id + limit  + ' isshow="1"'+' as="v"' +'}' + "\n"
   + type + "\n"
   + '{/loop}';
  document.getElementById("slide").value = sum;
};
// 搜索提交表单
function search(){
  var tpl = document.getElementById("tpl").value;
  if (tpl != '') {
    var tpl = '    <input type="hidden" name="searchtpl" value="' + tpl + '">' + "\n";
  } else {
    var tpl = "";
  }
  var scode = document.getElementById("scode").value;
  if (scode != '') {
    var scode = '    <input type="hidden" name="scode" value="' + scode + '">' + "\n";
  } else {
    var scode = '';
  }
  var sum = '<form action="{pboot:scaction}"  method="get">' + "\n"
   + '    关键字：<input type="text" name="keyword" >' + "\n" + tpl + scode
   + '    <button type="submit">搜索</button>' + "\n"
   + '</form>';
  document.getElementById("search1").value = sum;
};
// 搜索结果列表
function searchlist(){
  var num = document.getElementById("num").value;
  if (num != '') {
    var num = ' num=' + num;
  } else {
    var num = "";
  }
  var id = document.getElementById("id").value;
  if (id != '') {
    var id = ' scode=' + id;
  } else {
    var id = ' scode=*';
  }
  var order =  document.getElementById("order").value;
  if (order == 1 ) {
    var order = ' order=date';
  } else if (order == 0) {
    var order = "";
  } else if (order == 2) {
    var order = ' order=visits';
  } else if (order == 3) {
    var order = ' order=likes';
  } else if (order == 4) {
    var order = ' order=oppose';
  } else if (order == 5) {
    var order = ' order=sorting';
  }
  var s2 = document.getElementById("s2").value;
  if (s2 != '') {
    var s2 = " field='" + s2 + "'";
  } else {
    var s2 = '';
  }
  var s3 = document.getElementById("s3").value;
  if (s3 != '') {
    var s3 = " filter='" + s3 + "'";
  } else {
    var s3 = '';
  }
  var type =  document.getElementById("type").value;
  if (type == 0 ) {
    var type = ' fuzzy=0';
  } else if (type == 1) {
    var type = '';
  }
  var sum = "{pboot:search" + id + num + order + s2 + s3 + type + '}' + "\n"
   + '    <li><a href="[search:link]">[search:title]</a></li>' + "\n"
   + '{/pboot:search}';
  document.getElementById("searchlist").value = sum;
};
// 搜索结果列表
function select1(){
  var field = document.getElementById("field").value;
  if (field != '') {
    var field = field;
  } else {
    var field = "ext_*";
  }
  var sum = "<p>" + "\n"
   + "    类型：{pboot:selectall field=" + field + ' text=全部 class="btn btn-light" active="btn btn-info"} |' + "\n"
   + '    {pboot:select field=ext_leixing}' + "\n"
   + '    {pboot:if([select:i]>1)}|{/pboot:if}' + "\n"
   + '    <a href="[select:link]"{pboot:if(' + "'[select:value]'=='[select:current]'" + ')}class="active" {/pboot:if}>[select:value]</a>' + "\n"
   + '    {/pboot:select}' + "\n"
   + '</p>';
  document.getElementById("select1").value = sum;
};

  
  
  
  
